<template>
	<view class="content1">
		<view class="page-head">
			<uni-icons class="gap-top" type="arrow-left" color="white" size="30" @click="goBack"></uni-icons>
			<text class="white-font gap-top">参与记录</text>
		</view>
		<view class="package-box" style="padding-bottom: 90rpx">
			<view v-for="(item, index) in List" :key="index" class="gift-box">
				<view class="image-box">
					<view class="lflex">
						<text class="price">{{convertDateTimeSimple(item.created_at) }}</text>
						<text class="price"
							style="width: 246rpx;text-align:right">{{ item.count }}碰</text>
					</view>
					<view class="prize-list">
						<view class="prize-item"
							@click="showDialogImage(item)">
							<view class="prize-img">
								<image :src="item.image" />
							</view>
							<view class="prize-title">{{ item.name }}</view>
							<!-- <view class="price">¥{{ item.price }}</view> -->
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="empty-page" v-if="List.length==0">
			<view class="nofull">
				<image src="../../static/icons/package/nofull.png" class="nofullimg"></image>
				<text class="notitle">暂无数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	import moment from "moment";
	import {
		loadRecord
	} from "@/api/touch";
	export default {
		data() {
			return {
				List: [],
				total: 0,
				page: 1,
				gameId:0
			};
		},
		onLoad: function(options) {
			this.gameId = options.id
			this.getloadRecord();
		},
		onReachBottom() {
			if (this.List.length < this.total) {
				++this.page
				this.getloadRecord();
			}
		},
		async onPullDownRefresh() {
			this.page = 1
			await this.getloadRecord();
			uni.stopPullDownRefresh()
		},
		methods: {
      convertDateTimeSimple(iosDate) {
        const timeObj = moment(iosDate);
				return timeObj.format('YYYY-MM-DD HH:mm:ss')
      },
			convertDateTime(iosDate) {
				if (!iosDate) {
					return "-";
				}
				const date = new Date(iosDate);
				const year = date.getFullYear();
				const month = ("0" + (date.getMonth() + 1)).slice(-2); // 月份是从0开始的
				const day = ("0" + date.getDate()).slice(-2);
				const hours = ("0" + date.getHours()).slice(-2);
				const minutes = ("0" + date.getMinutes()).slice(-2);
				const seconds = ("0" + date.getSeconds()).slice(-2);

				return `${year}年${month}月${day}日 ${hours}时${minutes}分${seconds}秒`;
			},
			goBack() {
				uni.navigateBack({
					delta: 1,
				});
			},
			// 未申请
			async getloadRecord() {
				if (this.loading) {
					return
				}
				this.loading = true
			
				var obj = {
					page: this.page,
					size: 10,
					game_id: this.gameId
				}
				const res = await loadRecord(obj);
				const data = res.data || {};
				const items = data.items || [];
				this.List = this.List.concat(items);
				this.total = data.total
				this.loading = false
			},
		},
	};
</script>

<style lang="scss">
	@import "src/static/scss/common";

	.page-head {
		display: flex;
		gap: 10px;
		width: 100vw;
		line-height: 88px;
	}

	.package-box {
		// background-color: #0a050b;
	}

	.gift-box {
		display: flex;
		flex-direction: column;
		padding: 24rpx;
		background-color: #2e2e2e;
		margin: 24rpx;
		border-radius: 12rpx;

		.image-box {
			display: flex;
			flex-direction: column;
			align-items: flex-start;
			position: relative;

			.price {
				font-size: 30rpx;
				// color: #a1a1a1;
				color: rgba(225, 116, 237, 1);
			}
		}

		.lflex {
			width: 100%;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			margin-top: 16rpx;
		}
	}

	.app-container {
		flex-direction: column;
	}

	/* 标签栏样式 */
	.menu-tabs .van-tab--active {
		color: #ffffff;
		/* 字体颜色 */
		background-color: #ff8917;
		/* 标签背景颜色 */
		border-radius: 40px;
		/* 圆角标签背景 */
	}

	.menu-tabs {
		.van-tabs__line {
			background-color: #ff55ff;
			/* 线条颜色 */
			width: 40px;
			/*宽度 */
			height: 10px;
			/* 高度 */
			border-radius: 40px;
			/* 圆角 */
		}

		--tabs-nav-background-color: rgba(10, 5, 11, 1);
	}
	.prize-list {
		display: flex;
		overflow: scroll;
		flex: 1;
	
		.prize-item {
			margin: 0 20rpx;
	
			.prize-img {
				width: 150rpx;
				height: 156rpx;
				padding: 20rpx;
				background-image: url("~@/static/dongli-game.png");
				background-size: contain;
				background-repeat: no-repeat;
	
				image {
					width: 150rpx;
					height: 150rpx;
				}
	
				.tag {
					height: 40rpx;
					width: 60rpx;
					position: absolute;
					top: 20rpx;
					border-radius: 10rpx;
					font-size: 26rpx;
					text-align: center;
					line-height: 40rpx;
					background: linear-gradient(90deg, rgba(225, 116, 237, 1) 0%, rgba(47, 118, 236, 1) 100%);
				}
			}
	
			.prize-title {
				width: 190rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				color: #ffffff;
				font-size: 18rpx;
			}
	
			.price {
				font-size: 20rpx;
				color: #ECA2F5;
			}
		}
	}
</style>